package catchData;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;

import util.CatchDataUtil;

/**
 * @date 2014-02-04 11:43
 * @author suwy
 * @todo 抓取海南琼海天气数据
 */
public class CatchWeather {
	
	private static final String WEBURL = "http://www.weather.com.cn/weather/101310211.shtml";

	private void excute() {
		HttpClient client = CatchDataUtil.initHttpClient();
		StringBuilder cBuilder = new StringBuilder();
		GetMethod get = new GetMethod(WEBURL);
		CatchDataUtil.setHeaders(get, WEBURL, CatchDataUtil.getWebSite(WEBURL));
		try {
			client.executeMethod(get);
			cBuilder.append(get.getResponseBodyAsString());
			System.out.println(cBuilder);
			get.releaseConnection();
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[] args) {
		CatchWeather instance = new CatchWeather();
		instance.excute();
	}

}